<template>
	<view class="w-100">
		<view class="flex-1 mx-4">
			<view class="flex-1 py-4 font-s-45 font-w">分红提现申请</view>
			<view class="row-ac flex-1 font-s-4">
				<view class="text-light-grey">分红余额：</view>
				<view class="ml-3">¥ {{ dividendreport.total_dividend_amount }}</view>
			</view>
			<view class="font-s-2 text-muted mt-4 mb-3">提现金额不能大于分红余额</view>
			<view class="flex-1 row-ac mt-4">
				<view class="font-s-45 font-w text-light-grey">提现金额</view>
				<input type="text" value="" class="flex-1 ml-4 mr-3 py-4 font-s-6 border-bottom font-w"
					:placeholder="placeholder" v-model="FormData.extract_amount" />
			</view>
			<view class="flex-1 row" style="margin-top: 100rpx;">
				<view class="extract-box row font-s-35" @click="onExtract">申请提现</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		regionaldividendreportUrl,
		regionaldividendcreateUrl
	} from "@/api/index.js"
	export default {
		data() {
			return {
				dividendreport: {
					total_dividend_amount: 0,
					dividend_amount_add: 0,
					dividend_amount_minus: 0,
					dividend_amount_extract: 0
				},
				placeholder: '',
				FormData:{
					extract_amount:''
				}
			}
		},
		onLoad() {
			this.getRegionaldividendreport()
		},
		methods: {
			getRegionaldividendreport() {
				this.$R.get(regionaldividendreportUrl).then(res => {
					if (res.code == 200) {
						this.dividendreport = res.data
						console.log(this.dividendreport);
						this.placeholder = '可提现金额' + this.dividendreport.total_dividend_amount + '元'
					}
				})
			},
			onExtract(){
				this.$R.post(regionaldividendcreateUrl, this.FormData).then(res=>{
					if(res.code == 200){
						uni.showToast({
							title: '申请成功',
							icon: 'none'
						});
						setTimeout(() => {
							uni.navigateBack({
								delta: 1
							});
						}, 1300);
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				})
			}
		}
	}
</script>

<style>
	.extract-box{
		width: 260rpx;
		height: 82rpx;
		background-color: #000;
		color: #fff;
	}
</style>